package com.xopencode.list;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * @author Mcb
 * @date 2022/7/31
 * @apiNote
 */
public class Demo01 {
    public static void main(String[] args) {
        List<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(2);
        list.add(3);

        //for (Integer data : list){
        //    if (data.equals(1)){
        //        list.remove(data);
        //    }
        //}

        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()){
            Integer data = iterator.next();
            if (data.equals(1)){
                iterator.remove();
            }
        }

        for (Integer data : list) {
            System.out.println(data);
        }
    }
}
